#!/bin/csh

#**************************************************************#
#                                                              #
#  Job j280sum.del will delete the data for the current period #
#  from t280sum                                                #
#                                                              #
#**************************************************************#

set homedir  = '/home/j280sc/SCRIPTS'
cd $homedir
set sysdir   = '/home/j280sc/SYSTEM'
set fmtdir   = '/home/j280sc/TABLES'

echo ' '
echo '**=====================================================**'
echo '** j280sum.del:  begin execution                       **'
echo '**=====================================================**'

set server   = 'SCPROD3' 
set dbname   = 'd280db1' 
set tbname   = 't280sum'
set user     = `cut -c1-8 $sysdir/logon_id`
set pswd     = `cut -c10-18 $sysdir/logon_id`
set statusdb = 'd280db1'  
set sybrel   = 'source/1002'

#**************************************************************#
# erase any existing output file                               #
#**************************************************************#

if ( -e ${tbname}.outd ) then
  rm ${tbname}.outd
endif


#**************************************************************#
# delete the data for the current period                       #
#**************************************************************#
 
date
$SYBASE/${sybrel}/bin/isql -U$user -P$pswd -S${server} -o ${tbname}.outd <<EOF1
use ${statusdb}
go

print '*isql* ---------------------------------------------------------' 
print '*isql* Starting DELETE of WEEKLY data from d280db1.dbo.t280sum' 
print '*isql* ---------------------------------------------------------' 
go
declare @rc int
declare @rows int

delete from t280sum where f_fypd like '____W_'  

select @rc = @@error, @rows = @@rowcount
if (@rc != 0)
   begin
   print '*isql*****ERROR****'
   print '*isql*non-zero return from t280sum delete = %1!', @rc
   return
   end
else print '*isql* %1! Rows DELETED from d280db1.dbo.t280sum for Weekly Data',@rows
go
EOF1
 
rxx $sysdir/ERROR_CK_SYB ${tbname}.outd
set rc = $status

if ($rc != 0) then
  exit ($rc)
endif

echo ' '
echo '*AIX*Successful exit - ' 
echo ' '
echo '**=====================================================**'
echo '** j280sum.del:  end execution                         **'
echo '**=====================================================**'

exit
